package com.jstorm.count.service.commonroad.Impl;

import com.jstorm.count.dto.CommonExecution;
import com.jstorm.count.dto.ResultDtoUtile;
import com.jstorm.count.enums.ResultEnum;
import com.jstorm.count.mapper.commonroad.CommonroadMapper;
import com.jstorm.count.pojo.Result;
import com.jstorm.count.service.commonroad.CommonroadService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @ProjectName: common
 * @Package: com.jstorm.count.service.network.Impl
 * @ClassName: NetworkServiceImpl
 * @Description:
 * @Author: Mr_hu
 * @CreateDate: 2018/12/28 18:39
 * ***********************************************************
 * @UpdateUser: Mr_hu
 * @UpdateDate: 2018/12/28 18:39
 * @UpdateRemark: The modified content
 * @Version: 1.0
 * ***********************************************************
 * Copyright: Copyright (c) 2018
 **/
@Service
public class CommonroadServiceImpl implements CommonroadService {



    @Autowired
    @SuppressWarnings("all")
    private CommonroadMapper commonroadMapper;

    /**
     * 查数据包下所有数据
     * @return
     */
    @Override
    public CommonExecution selectNumber() {
        //数据库 查询
        List<Map<String, Object>> commonroad = commonroadMapper.selectCommonroadCount();
        //失败
        if (commonroad == null){
         return new CommonExecution(ResultEnum.SELECTLISTMAP_NULL);
        }
        //成功
        return new CommonExecution(ResultEnum.SELECTLISTMAP_SUCCESS,commonroad);
    }

    /**
     * 总数
     * @return
     */
    @Override
    public CommonExecution selectTotal(){
        //数据库 查询
        List<Map<String, Object>>  commonroadTotal = commonroadMapper.selectCommonroadTotal();
        //失败
        if (commonroadTotal == null){
            return new CommonExecution(ResultEnum.SELECTTOTAL_NULL);
        }
        //成功
        return new CommonExecution(ResultEnum.SELECTTOTAL_SUCCESS,commonroadTotal);
    }

    /**
     *
     * 用户表下整个数量
     * @return
     */
    @Override
    public List<Object> selectSums() {
        //数据库 查询
        List<Object>  commonroadSums = commonroadMapper.selectCommonroadSums();
        if (commonroadSums == null){
            throw new RuntimeException("Service层数量查询为空!");
        }

        return commonroadSums;
    }


}
